xen/arm: p2m: Handle preemption when freeing intermediate page tables
authorJulien Grall <jgrall@amazon.com>
Mon, 6 Jun 2022 06:17:26 +0000 (06:17 +0000)
committerJan Beulich <jbeulich@suse.com>
Tue, 11 Oct 2022 12:20:56 +0000 (14:20 +0200)
commit3202084566bba0ef0c45caf8c24302f83d92f9c8
tree426cb67f5643cae386e569a20cb1b19ba412b5d3
parent3ebe773293e3b945460a3d6f54f3b91915397bab
xen/arm: p2m: Handle preemption when freeing intermediate page tables

At the moment the P2M page tables will be freed when the domain structure
is freed without any preemption. As the P2M is quite large, iterating
through this may take more time than it is reasonable without intermediate
preemption (to run softirqs and perhaps scheduler).

Split p2m_teardown() in two parts: one preemptible and called when
relinquishing the resources, the other one non-preemptible and called
when freeing the domain structure.

As we are now freeing the P2M pages early, we also need to prevent
further allocation if someone call p2m_set_entry() past p2m_teardown()
(I wasn't able to prove this will never happen). This is done by
the checking domain->is_dying from previous patch in p2m_set_entry().

Similarly, we want to make sure that no-one can accessed the free
pages. Therefore the root is cleared before freeing pages.

This is part of CVE-2022-33746 / XSA-410.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Tested-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/domain.c
xen/arch/arm/include/asm/p2m.h
xen/arch/arm/p2m.c